//
//  MergeViewController.swift
//  testRxSwift
//
//  Created by 火星人 on 2017/7/25.
//  Copyright © 2017年 火星人. All rights reserved.
//

import UIKit
import RxSwift

class MergeViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addTapWithHandle { (tap) in
            
            let disBag = DisposeBag()
            
            let subject1 = PublishSubject<String>()
            let subject2 = PublishSubject<String>()
            
            Observable.of(subject1, subject2)
                .merge()
                .subscribe({ (eve) in
                    print(eve)
                })
                .disposed(by: disBag)
            
            subject1.onNext("1")
            subject1.onNext("2")
            
            subject2.onNext("21")
            
            subject1.onNext("3")
            
            subject2.onNext("22")
        }
    }

}
